
<template>
  <div class="container">
    <!-- 移动端菜单切换按钮 -->
    <div class="mobile-menu-toggle md:hidden">
      <el-button 
        type="primary" 
        circle 
        size="small"
        class="menu-toggle-btn"
        @click="toggleMobileMenu"
      >
        <el-icon><Menu /></el-icon>
      </el-button>
    </div>

    <!-- 头部：包含标题、添加/导出按钮 -->
    <div class="flex flex-wrap items-center justify-between mb-6 gap-3">
      <!-- 标题 -->
      <div>
        <h1 class="page-title text-2xl font-bold">车辆管理</h1>
        <p class="text-gray-500">管理所有车辆基本信息、状态和相关记录</p>
      </div>
      <!-- 添加/导出按钮 -->
      <div class="flex gap-2 flex-wrap">
        <el-button type="primary" @click="openDialog()" class="btn-with-icon">
          <el-icon class="mr-1"><Plus /></el-icon>添加车辆
        </el-button>
        <el-button type="success" @click="exportData" class="btn-with-icon">
          <el-icon class="mr-1"><Download /></el-icon>导出数据
        </el-button>
        <el-button type="warning" @click="openImportDialog" class="btn-with-icon">
          <el-icon class="mr-1"><Upload /></el-icon>导入数据
        </el-button>
        <el-button @click="downloadTemplate" class="btn-with-icon" plain>
          <el-icon class="mr-1"><Document /></el-icon>下载模板
        </el-button>
      </div>
    </div>

    <!-- 搜索区域框 -->
    <el-card shadow="hover" class="mb-6 card-with-hover">
      <div class="search-container">
        <!-- 车牌号搜索 -->
        <div class="search-item">
          <el-input
            v-model="searchForm.plateNumber"
            placeholder="请输入车牌号"
            class="search-input"
            clearable
          >
            <template #prefix>
              <el-icon class="search-icon"><Van /></el-icon>
            </template>
          </el-input>
        </div>
        
        <!-- 车辆类型搜索 -->
        <div class="search-item">
          <el-select
            v-model="searchForm.vehicleType"
            placeholder="请选择车辆类型"
            class="search-input"
            clearable
          >
            <el-option
              v-for="type in vehicleTypes"
              :key="type"
              :label="type"
              :value="type"
            />
          </el-select>
        </div>
        
        <!-- 车辆状态搜索 -->
        <div class="search-item">
          <el-select
            v-model="searchForm.status"
            placeholder="请选择车辆状态"
            class="search-input"
            clearable
          >
            <el-option
              v-for="(label, value) in statusOptions"
              :key="value"
              :label="label"
              :value="value === '0' ? '0' : value"
            />
          </el-select>
        </div>
        
        <!-- 操作按钮 -->
        <div class="search-actions">
          <el-button type="primary" @click="handleSearch" class="search-btn">
            <el-icon class="mr-1"><Search /></el-icon>查询
          </el-button>
          
          <el-button @click="resetSearch" class="reset-btn" type="info" plain>
            <el-icon class="mr-1"><Refresh /></el-icon>重置
          </el-button>
        </div>
      </div>
    </el-card>

    <!-- 数据表格 -->
    <el-card shadow="hover" class="overflow-hidden card-with-hover">
      <el-table
        v-loading="loading"
        :data="filteredVehicles"
        border
        stripe
        style="width: 100%"
        :header-cell-class-name="'bg-gray-100 dark:bg-gray-700'"
        class="custom-table"
        fit
        @sort-change="handleSortChange"
      >
        <!-- 固定列 -->
        <el-table-column prop="id" label="ID" width="80" align="center" sortable="custom" fixed="left" />
        <el-table-column prop="plateNumber" label="车牌号" min-width="120" sortable="custom" fixed="left" />
        
        <!-- 中等屏幕及以上显示的列 -->
        <el-table-column prop="vehicleType" label="车辆类型" min-width="120" sortable="custom" class-name="hide-on-mobile" />
        <el-table-column prop="brand" label="品牌" min-width="120" sortable="custom" class-name="hide-on-mobile" />
        <el-table-column prop="model" label="型号" min-width="120" sortable="custom" class-name="hide-on-mobile" />
        <el-table-column prop="color" label="颜色" min-width="100" sortable="custom" class-name="hide-on-mobile" />
        <el-table-column prop="status" label="状态" min-width="100" sortable="custom" class-name="hide-on-mobile">
          <template #default="{ row }">
            <el-tag :type="getStatusType(row.status)">{{ getStatusLabel(row.status) }}</el-tag>
          </template>
        </el-table-column>
        
        <!-- 操作列 -->
        <el-table-column label="操作" width="120" fixed="right">
          <template #default="scope">
            <div class="action-buttons">
              <el-button 
                type="primary" 
                size="small"
                circle
                @click="editVehicle(scope.row)"
                class="edit-btn"
              >
                <el-icon><Edit /></el-icon>
              </el-button>
              <el-button 
                type="danger" 
                size="small"
                circle
                @click="deleteVehicle(scope.row)"
                class="delete-btn"
              >
                <el-icon><Delete /></el-icon>
              </el-button>
            </div>
          </template>
        </el-table-column>
      </el-table>

      <!-- 分页器 -->
      <div class="pagination-container mt-4 flex justify-center">
        <el-pagination
          :current-page="currentPage"
          :page-size="pageSize"
          :page-sizes="DEFAULT_PAGE_SIZES"
          :total="totalVehicles"
          layout="total, sizes, prev, pager, next, jumper"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          background
          class="custom-pagination"
        />
      </div>
    </el-card>

    <!-- 添加/编辑对话框 -->
    <el-dialog
      v-model="dialogVisible"
      :title="isEdit ? '编辑车辆' : '添加车辆'"
      width="500px"
      destroy-on-close
      class="custom-dialog"
    >
      <el-form
        ref="formRef"
        :model="vehicleForm"
        :rules="rules"
        label-width="100px"
        label-position="right"
        class="form-container"
      >
        <el-form-item label="车牌号" prop="plateNumber">
          <el-input v-model="vehicleForm.plateNumber" placeholder="请输入车牌号" />
        </el-form-item>
        <el-form-item label="车辆类型" prop="vehicleType">
          <el-select v-model="vehicleForm.vehicleType" placeholder="请选择车辆类型" style="width: 100%">
            <el-option
              v-for="type in vehicleTypes"
              :key="type"
              :label="type"
              :value="type"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="品牌" prop="brand">
          <el-input v-model="vehicleForm.brand" placeholder="请输入品牌" />
        </el-form-item>
        <el-form-item label="型号" prop="model">
          <el-input v-model="vehicleForm.model" placeholder="请输入型号" />
        </el-form-item>
        <el-form-item label="颜色" prop="color">
          <el-input v-model="vehicleForm.color" placeholder="请输入颜色" />
        </el-form-item>
        <el-form-item label="位置" prop="location">
          <el-input v-model="vehicleForm.location" placeholder="请输入车辆当前位置" />
        </el-form-item>
        <el-form-item label="车架号" prop="frameNumber">
          <el-input v-model="vehicleForm.frameNumber" placeholder="请输入车架号" />
        </el-form-item>
        <el-form-item label="发动机号" prop="engineNumber">
          <el-input v-model="vehicleForm.engineNumber" placeholder="请输入发动机号" />
        </el-form-item>
        <el-form-item label="购买价格" prop="purchasePrice">
          <el-input-number v-model="vehicleForm.purchasePrice" :min="0" :precision="2" :step="1000" style="width: 100%" placeholder="请输入购买价格" />
        </el-form-item>
        <el-form-item label="当前里程" prop="currentMileage">
          <el-input-number v-model="vehicleForm.currentMileage" :min="0" :precision="1" :step="100" style="width: 100%" placeholder="请输入当前里程(km)" />
        </el-form-item>
        <el-form-item label="购买日期" prop="purchaseDate">
          <el-date-picker
            v-model="vehicleForm.purchaseDate"
            type="date"
            placeholder="选择购买日期"
            style="width: 100%"
            value-format="YYYY-MM-DD"
          />
        </el-form-item>
        <el-form-item label="登记日期" prop="registrationDate">
          <el-date-picker
            v-model="vehicleForm.registrationDate"
            type="date"
            placeholder="选择登记日期"
            style="width: 100%"
            value-format="YYYY-MM-DD"
          />
        </el-form-item>
        <el-form-item label="保险到期日" prop="insuranceExpiry">
          <el-date-picker
            v-model="vehicleForm.insuranceExpiry"
            type="date"
            placeholder="选择保险到期日"
            style="width: 100%"
            value-format="YYYY-MM-DD"
          />
        </el-form-item>
        <el-form-item label="年检到期日" prop="inspectionExpiry">
          <el-date-picker
            v-model="vehicleForm.inspectionExpiry"
            type="date"
            placeholder="选择年检到期日"
            style="width: 100%"
            value-format="YYYY-MM-DD"
          />
        </el-form-item>
        <el-form-item label="状态" prop="status">
          <el-select v-model="vehicleForm.status" placeholder="请选择状态" style="width: 100%">
            <el-option
              v-for="(label, value) in statusOptions"
              :key="value"
              :label="label"
              :value="value === '0' ? '0' : value"
            />
          </el-select>
        </el-form-item>
      </el-form>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="dialogVisible = false">取消</el-button>
          <el-button type="primary" @click="submitForm">确定</el-button>
        </span>
      </template>
    </el-dialog>

    <!-- 导入对话框 -->
    <el-dialog
      v-model="importDialogVisible"
      title="导入车辆数据"
      width="500px"
      destroy-on-close
      class="custom-dialog"
    >
      <div class="import-container">
        <el-upload
          class="upload-demo"
          drag
          action="#"
          :auto-upload="false"
          :on-change="handleFileChange"
          :limit="1"
          :file-list="fileList"
          accept=".xlsx,.xls"
        >
          <el-icon class="el-icon--upload"><upload-filled /></el-icon>
          <div class="el-upload__text">
            拖拽文件到此处或 <em>点击上传</em>
          </div>
          <template #tip>
            <div class="el-upload__tip">
              请上传Excel文件(.xlsx或.xls)，文件大小不超过10MB
            </div>
          </template>
        </el-upload>
        
        <div class="import-tips mt-4">
          <p class="text-gray-500">
            <el-icon><info-filled /></el-icon>
            导入说明：
          </p>
          <ol class="text-gray-500 text-sm pl-6 list-decimal">
            <li>请先下载导入模板，按照模板格式填写数据</li>
            <li>必填字段：车牌号、车辆类型、品牌、状态</li>
            <li>日期格式：YYYY-MM-DD，如2023-01-01</li>
            <li>状态值：1=正常使用，2=维修中，3=停用，0=报废</li>
          </ol>
        </div>
      </div>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="importDialogVisible = false">取消</el-button>
          <el-button type="primary" @click="submitImport" :disabled="!selectedFile">导入</el-button>
        </span>
      </template>
    </el-dialog>
  </div>
</template>

<script>
import { ref, reactive, onMounted, computed } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { Plus, Download, Search, Refresh, Edit, Delete, Menu, Van, Upload, Document, UploadFilled, InfoFilled } from '@element-plus/icons-vue'
import axios from 'axios'
import { getToken } from '@/utils/auth'
import router from '@/router'
import { vehicleApi } from '@/api/index'

export default {
  name: 'Vehicles',
  components: {
    Plus, Download, Search, Refresh, Edit, Delete, Menu, Van, Upload, Document, UploadFilled, InfoFilled
  },
  setup() {
    // 常量
    const DEFAULT_PAGE_SIZES = [10, 20, 50, 100]
    
    // 表格相关
    const loading = ref(false)
    const vehicles = ref([])
    const totalVehicles = ref(0)
    const currentPage = ref(1)
    const pageSize = ref(10)
    const sortBy = ref('id') // 修改默认排序字段为id
    const sortOrder = ref('descending')
    // 移除多字段排序状态数组
    const dialogVisible = ref(false)
    const isEdit = ref(false)
    const formRef = ref(null)

    // 导入相关
    const importDialogVisible = ref(false)
    const selectedFile = ref(null)
    const fileList = ref([])

    // 验证规则
    const rules = {
      plateNumber: [
        { required: true, message: '请输入车牌号', trigger: 'blur' },
        { min: 5, max: 10, message: '车牌号长度应在5到10个字符之间', trigger: 'blur' }
      ],
      vehicleType: [
        { required: true, message: '请选择车辆类型', trigger: 'change' }
      ],
      brand: [
        { required: true, message: '请输入品牌', trigger: 'blur' }
      ],
      status: [
        { required: true, message: '请选择状态', trigger: 'change' }
      ]
    }

    // 状态选项
    const statusOptions = {
      '1': '正常使用',
      '2': '维修中',
      '3': '停用',
      '0': '报废'
    }
    
    // 搜索表单
    const searchForm = reactive({
      plateNumber: '',
      vehicleType: '',
      status: ''
    })
    
    // 车辆表单
    const vehicleForm = reactive({
      id: '',
      plateNumber: '',
      vehicleType: '',
      brand: '',
      model: '',
      color: '',
      location: '',
      engineNumber: '',
      frameNumber: '',
      purchaseDate: '',
      purchasePrice: '',
      currentMileage: '',
      insuranceExpiry: '',
      inspectionExpiry: '',
      status: '1',
      remark: ''
    })
    
    // 车辆类型选项
    const vehicleTypes = ref([])
    
    // 计算属性：过滤后的车辆列表
    const filteredVehicles = computed(() => {
      // 处理状态显示
      return vehicles.value.map(vehicle => {
        // 确保状态值格式一致
        if (vehicle.status !== undefined) {
          vehicle.status = String(vehicle.status);
          vehicle.statusText = getStatusLabel(vehicle.status);
          vehicle.statusType = getStatusType(vehicle.status);
        } else {
          vehicle.status = '1'; // 默认为正常使用状态
          vehicle.statusText = '正常使用';
          vehicle.statusType = 'success';
        }
        return vehicle;
      });
    })

    // 检查登录状态
    const checkLoginStatus = () => {
      const token = getToken()
      if (!token) {
        ElMessage.error('请先登录')
        router.push('/login')
        return false
      }
      return true
    }

    // 方法
    const loadVehicles = async () => {
      loading.value = true
      try {
        // 构造API请求参数
        const params = {
          current: currentPage.value,
          size: pageSize.value,
          searchTerm: searchForm.plateNumber || null,
          vehicleType: searchForm.vehicleType || null,
          status: searchForm.status !== '' ? searchForm.status : null,
          // 使用单字段排序
          orderBy: sortBy.value,
          orderType: sortOrder.value
        }
        
        console.log('搜索参数:', params);
        
        // 调用vehicleApi的getVehicleList方法
        const page = await vehicleApi.getVehicleList(params)
        
        // 解析返回的数据
        if (page && page.records) {
          // 处理每条记录的数据格式
          const processedRecords = page.records.map(vehicle => {
            // 确保状态值是数字
            if (vehicle.status === undefined || vehicle.status === null) {
              vehicle.status = '1'; // 默认为正常使用状态
            } else {
              vehicle.status = String(vehicle.status);
            }
            
            // 确保其他字段不为空
            vehicle.plateNumber = vehicle.plateNumber || '未知车牌';
            vehicle.vehicleType = vehicle.vehicleType || '未知类型';
            vehicle.brand = vehicle.brand || '未知品牌';
            vehicle.model = vehicle.model || '未知型号';
            vehicle.color = vehicle.color || '未知颜色';
            
            return vehicle;
          });
          
          vehicles.value = processedRecords;
          totalVehicles.value = page.total || 0;
          console.log('车辆数据加载成功:', vehicles.value.length, '条记录')
        } else {
          vehicles.value = []
          totalVehicles.value = 0
          console.warn('返回的车辆数据格式不正确:', page)
        }
      } catch (error) {
        console.error('加载车辆数据失败:', error)
          ElMessage.error('加载数据失败，请稍后重试')
      } finally {
        loading.value = false
      }
    }

    const handleSearch = () => {
      currentPage.value = 1
      loadVehicles()
    }

    const resetSearch = () => {
      Object.keys(searchForm).forEach(key => {
        searchForm[key] = ''
      })
      handleSearch()
    }

    const handleSortChange = ({ prop, order }) => {
      if (prop) {
        // 单字段排序逻辑
        sortBy.value = prop
        sortOrder.value = order || 'descending'
        
        console.log('当前排序字段:', sortBy.value, sortOrder.value)
        loadVehicles()
      }
    }

    const handleSizeChange = (size) => {
      pageSize.value = size
      loadVehicles()
    }

    const handleCurrentChange = (page) => {
      currentPage.value = page
      loadVehicles()
    }

    const openDialog = (isEditMode = false) => {
      isEdit.value = isEditMode
      dialogVisible.value = true
      if (!isEditMode) {
        // 新增模式，重置表单
        Object.keys(vehicleForm).forEach(key => {
          vehicleForm[key] = key === 'status' ? '1' : ''
        })
      }
    }

    const editVehicle = (row) => {
      // 编辑模式，复制数据到表单
      console.log('编辑的原始数据:', JSON.stringify(row));
      
      // 手动设置每个字段，确保正确获取
      vehicleForm.id = row.id;
      vehicleForm.plateNumber = row.plateNumber || '';
      vehicleForm.vehicleType = row.vehicleType || '';
      vehicleForm.brand = row.brand || '';
      vehicleForm.model = row.model || '';
      vehicleForm.color = row.color || '';
      vehicleForm.location = row.location || '';
      vehicleForm.frameNumber = row.frameNumber || '';
      vehicleForm.engineNumber = row.engineNumber || '';
      vehicleForm.purchaseDate = row.purchaseDate || '';
      vehicleForm.purchasePrice = row.purchasePrice || null;
      vehicleForm.currentMileage = row.currentMileage || null;
      vehicleForm.insuranceExpiry = row.insuranceExpiry || '';
      vehicleForm.inspectionExpiry = row.inspectionExpiry || '';
      vehicleForm.status = row.status !== undefined ? row.status : '1';
      vehicleForm.remark = row.remark || '';
      
      console.log('设置后的表单数据:', JSON.stringify(vehicleForm));
      openDialog(true);
    }

    const deleteVehicle = (row) => {
      ElMessageBox.confirm(
        `确认删除车牌号为 ${row.plateNumber} 的车辆记录吗？`,
        '警告',
        {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }
      ).then(async () => {
        try {
          // 调用vehicleApi删除车辆
          await vehicleApi.deleteVehicle(row.id)
          ElMessage.success('删除成功')
          loadVehicles()
        } catch (error) {
          console.error('删除车辆失败:', error)
            ElMessage.error('删除失败，请稍后重试')
        }
      }).catch(() => {
        // 用户取消删除
      })
    }

    const submitForm = () => {
      formRef.value.validate(async (valid) => {
        if (valid) {
          try {
            loading.value = true
            // 确保表单数据完整性
            if (!vehicleForm.status) {
              vehicleForm.status = '1'; // 默认为正常使用状态
            }
            
            // 处理日期字段，确保格式正确
            const dataToSubmit = { ...vehicleForm };
            console.log('提交前的表单数据:', JSON.stringify(dataToSubmit));
            
            // 确保日期字段使用正确的格式
            ['purchaseDate', 'insuranceExpiry', 'inspectionExpiry'].forEach(dateField => {
              if (!dataToSubmit[dateField]) {
                dataToSubmit[dateField] = null; // 如果没有日期，设为null而不是空字符串
              }
            });
            
            // 处理数字字段，确保格式正确
            if (dataToSubmit.purchasePrice === '') {
              dataToSubmit.purchasePrice = null;
            }
            
            if (dataToSubmit.currentMileage === '') {
              dataToSubmit.currentMileage = null;
            }
            
            console.log('处理后准备提交的数据:', JSON.stringify(dataToSubmit));
            
            // 调用vehicleApi添加或更新车辆
            if (isEdit.value) {
              await vehicleApi.updateVehicle(dataToSubmit)
              ElMessage.success('更新成功')
            } else {
              await vehicleApi.addVehicle(dataToSubmit)
              ElMessage.success('添加成功')
            }
            dialogVisible.value = false
            loadVehicles()
          } catch (error) {
            console.error('提交表单失败:', error)
            ElMessage.error('操作失败，请稍后重试')
          } finally {
            loading.value = false
          }
        }
      })
    }

    const getStatusLabel = (status) => {
      // 确保状态是字符串
      const statusStr = String(status);
      return statusOptions[statusStr] || '未知状态';
    }

    const getStatusType = (status) => {
      // 确保状态是字符串
      const statusStr = String(status);
      const types = {
        '1': 'success',  // 正常使用
        '2': 'warning',  // 维修中
        '3': 'info',     // 停用
        '0': 'danger'    // 报废
      }
      return types[statusStr] || 'info';
    }

    const toggleMobileMenu = () => {
      // 控制移动端菜单显示
      const event = new CustomEvent('toggle-sidebar')
      window.dispatchEvent(event)
    }

    const exportData = async () => {
      try {
        loading.value = true
        ElMessage.info('正在导出数据，请稍候...')
        
        // 构建导出参数，使用当前的筛选条件
        const params = {
          searchTerm: searchForm.plateNumber || null,
          vehicleType: searchForm.vehicleType || null,
          status: searchForm.status !== '' ? searchForm.status : null
        }
        
        console.log('导出参数:', params)
        
        try {
          // 使用vehicleApi获取下载URL
          const downloadUrl = vehicleApi.exportVehicles(params);
          console.log('导出URL:', downloadUrl);
          
          // 使用窗口打开下载链接
          window.open(downloadUrl, '_blank');
          
          ElMessage.success('数据导出请求已发送，请在新窗口中查看下载进度');
          loading.value = false;
          
        } catch (apiError) {
          console.error('导出API调用失败:', apiError)
          ElMessage.error(`导出失败: ${apiError.message || '未知错误'}`)
          throw apiError
        }
      } catch (error) {
        console.error('导出数据失败:', error)
        ElMessage.error('导出失败，请稍后重试')
        loading.value = false
      }
    }
    
    // 导入相关方法
    const handleFileChange = (file) => {
      // 只保留最新选择的文件
      fileList.value = [file]
      selectedFile.value = file.raw
      console.log('已选择文件:', file.name)
    }
    
    const openImportDialog = () => {
      importDialogVisible.value = true
      fileList.value = []
      selectedFile.value = null
    }
    
    const submitImport = async () => {
      if (!selectedFile.value) {
        ElMessage.warning('请先选择要导入的文件')
        return
      }
      
      try {
        loading.value = true
        ElMessage.info('正在导入数据，请稍候...')
        
        // 调用API导入文件
        await vehicleApi.importVehicles(selectedFile.value)
        
        ElMessage.success('数据导入成功')
        importDialogVisible.value = false
        loadVehicles() // 重新加载数据
      } catch (error) {
        console.error('导入数据失败:', error)
        ElMessage.error(`导入失败: ${error.message || '未知错误'}`)
      } finally {
        loading.value = false
      }
    }
    
    const downloadTemplate = () => {
      try {
        // 使用window.open直接下载模板
        const templateUrl = vehicleApi.downloadImportTemplate()
        window.open(templateUrl, '_blank')
        ElMessage.success('模板下载请求已发送，请在新窗口中查看下载进度')
      } catch (error) {
        console.error('下载模板失败:', error)
        ElMessage.error('下载模板失败，请稍后重试')
      }
    }

    onMounted(async () => {
      try {
        // 获取车辆类型列表
        const types = await vehicleApi.getVehicleTypes()
        if (Array.isArray(types)) {
          vehicleTypes.value = types
        }
      } catch (error) {
        console.error('获取车辆类型失败:', error)
      }
      
      // 加载车辆数据
      loadVehicles()
    })

    return {
      DEFAULT_PAGE_SIZES,
      vehicleTypes,
      statusOptions,
      formRef,
      dialogVisible,
      isEdit,
      vehicleForm,
      searchForm,
      loading,
      vehicles,
      currentPage,
      pageSize,
      totalVehicles,
      filteredVehicles,
      rules,
      loadVehicles,
      handleSearch,
      resetSearch,
      handleSortChange,
      handleSizeChange,
      handleCurrentChange,
      openDialog,
      editVehicle,
      deleteVehicle,
      submitForm,
      getStatusLabel,
      getStatusType,
      toggleMobileMenu,
      exportData,
      // 导入相关
      openImportDialog,
      importDialogVisible,
      fileList,
      selectedFile,
      handleFileChange,
      submitImport,
      downloadTemplate
    }
  }
}
</script>

<style scoped>
.container {
  padding: 1rem;
  position: relative;
}

.search-container {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.search-item {
  flex: 1;
  min-width: 200px;
}

.search-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.action-buttons {
  display: flex;
  gap: 8px;
}

.mobile-menu-toggle {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 10;
}

@media (max-width: 768px) {
  .hide-on-mobile {
    display: none;
  }
  
  .search-item {
    min-width: 100%;
  }
  
  .search-actions {
    width: 100%;
    margin-top: 12px;
    justify-content: center;
  }
}
</style> 